﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BDSim
{
    public class SendReceiveDeviceDataProvider : BDSimDataProvider
    {
        private SendReceiveDevice _Parent;

        public SendReceiveDevice Parent
        {
            get { return _Parent; }
            set { _Parent = value; }
        }

        #region 命令定义
        public override void DefineCommand()
        {

            MenuCommand ClockReport = new MenuCommand() { Header = "生成报告" };
            ClockReport.DefineExcuteCommand(ClockReport_Execute, ClockReport_CanExecute);
            MenuCommand ClockFigure = new MenuCommand() { Header = "生成图表" };
            ClockFigure.DefineExcuteCommand(ClockFigure_Execute, ClockFigure_CanExecute);
            MenuCommand ClockDataExport = new MenuCommand() { Header = "钟差数据" };
            ClockDataExport.SubMenuCommandList.Add(ClockReport);
            ClockDataExport.SubMenuCommandList.Add(ClockFigure);
            MenuCommandList.Add(ClockDataExport);

            //MenuCommand mcdDelete = new MenuCommand() { Header = "删除" };
            //mcdDelete.DefineExcuteCommand(mcdDelete_Execute, mcdDelete_CanExecute);
            //MenuCommandList.Add(mcdDelete);

        }
        #endregion



        #region 命令执行方法

        #region 删除命令执行方法
        /// <summary>
        /// 删除接收机功能命令执行方法
        /// </summary>
        /// <param name="param"></param>
        void mcdDelete_Execute(object param)
        {
            if (Parent.Parent2.Type == EStationType.InjectionStation)
            {
               ((InjectionStation)(Parent.Parent2)).InjectSendReceivers.Remove(this.Parent);
            }
            
        }
        /// <summary>
        /// 删除接收机功能命令可执行控制
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        bool mcdDelete_CanExecute(object param)
        {
            bool flag = true;

            return flag;
        }

        #endregion


        #region 执行方法模板
        /// <summary>
        /// XXX 功能命令执行方法
        /// </summary>
        /// <param name="param"></param>
        void XXX_Execute(object param)
        {

        }
        /// <summary>
        /// XXX功能命令可执行控制
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        bool XXX_CanExecute(object param)
        {
            bool flag = true;

            return flag;
        }
        #endregion

        #region 钟差报告执行方法
        /// <summary>
        /// XXX 功能命令执行方法
        /// </summary>
        /// <param name="param"></param>
        void ClockReport_Execute(object param)
        {
            DataReportView dataPreview = new DataReportView();
            List<ClkSimData> InterSatClkErrList = new List<ClkSimData>();
            InterSatClkErrList = Parent.Parent2.GenerateStepCLKErr();
            dataPreview.InitClkData(InterSatClkErrList, Parent.Name);
            MainDispatcher.DlgAddLayoutDocument(dataPreview, Parent.Name);
        }
        /// <summary>
        /// XXX功能命令可执行控制
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        bool ClockReport_CanExecute(object param)
        {
            bool flag = true;

            return flag;
        }
        #endregion

        #region 钟差绘图执行方法
        /// <summary>
        /// XXX 功能命令执行方法
        /// </summary>
        /// <param name="param"></param>
        void ClockFigure_Execute(object param)
        {
            DataFigureView clkFigureView = new DataFigureView();
            List<ClkSimData> InterSatClkErrList = new List<ClkSimData>();
            InterSatClkErrList = Parent.Parent2.GenerateStepCLKErr();
            clkFigureView.InitClkCharts(Parent.Name,InterSatClkErrList);
            MainDispatcher.DlgAddLayoutDocument(clkFigureView, Parent.Name + "_钟差图表");
        }
        /// <summary>
        /// XXX功能命令可执行控制
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        bool ClockFigure_CanExecute(object param)
        {
            bool flag = true;

            return flag;
        }
        #endregion

        #endregion
    }
}
